<@t.html>
	<link href="public/common/chosen/chosen.css" type="text/css" rel="stylesheet">
	<link rel="stylesheet" href="public/static/ztree/css/zTreeStyle/zTreeStyle.css">
	<@t.container title="添加文章" >
				<@t.form id="add_form">
					<#if bean??>
        				<input type="hidden" id="id" name="id" value="${bean.id}"/>	
					</#if>
					<@t.from_f_line title="分类属性">
						<@t.check id="hot" title="热点" value="1" defValue="${bean.hot!}" />
						<@t.check id="vedio" title="视频" value="1" defValue="${bean.vedio!}" />
						<@t.check id="pictrue" title="图片" value="1" defValue="${bean.pictrue!}" />
						<@t.check id="attachment" title="附件" value="1" defValue="${bean.attachment!}" />
						<@t.check id="recomment" title="推荐" value="1" defValue="${bean.recomment!}" />						
					</@t.from_f_line>
					<@t.from_f_line title="置顶设置">
						<@t.check id="top" title="置顶" value="1" defValue="${bean.top!}" />
						<@t.datepicker id="top_end_time" value="${bean.top_end_time}" help="在此期限之前处于置顶状态，过期则取消置顶，不填则不限制天数"/>	
					</@t.from_f_line>			
					<@t.text title="标题" id="title" value="${bean.title!''}" />    
					<@t.text title="作者" id="author" value="${bean.author!''}" />    
					<@t.text title="标签" id="tags" value="${bean.tags!''}" />    
					<@t.select title="是否原创" id="type" datas={"1":"原创","2":"转载"} defaultValue="${bean.type!''}" />    
                	<@t.text title="来源" id="source" value="${bean.source!''}" />
                	<@t.text title="原文链接" id="source_url" value="${bean.source_url!''}" />
                	<@t.treeSelect title="栏目" help="请选择所属栏目" id="category_id"  value="${bean.category_id!category}" />
                	<@t.textarea title="摘要" id="summary" value="${bean.summary!''}" />
                	<@t.uploader title="Logo图片" id="logoPic" value="${bean.logoPic!''}" />
                	<@t.editor title="内容" id="text" value="${bean.text!''}" />
					<@t.submitBtn title="保存"/>
               </@t.form>
	</@t.container>
	<!-- 加载百度编辑器最小版本 -->
	<script type="text/javascript" src="public/common/json.js"></script>
	<script type="text/javascript" src="public/common/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="public/common/ueditor/ueditor.all.min.js"></script>
	<script type="text/javascript" src="public/common/chosen/chosen.jquery.min.js"></script>
	<script type="text/javascript" src="public/static/ztree/js/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript">
	function changeType(flag){
		if(flag==1){
			$('.zz').css('display','none');
		}else{
			$('.zz').css('display','block');
		}
	 }
		$(function(){
			changeType($('input[name=type]').val());
    	 //绑定上传
         $('#logoPic-uploader').uploadify({params:{'channel':'normal_pic'},"fileTypeExts":"*.jpg;*.png;*.gif"});
         //标签
	    //  $('#label').chosen({max_selected_options: 5});
		//提交表单
       	  $('#add_form').validator({
        		theme: 'yellow_right_effect',  //设置theme
        		stopOnError: true, //
        		showOk:false,
        	    fields: {
        	        "name": {
        	            rule: "required;",
        	            ok: "",
        	            tip:"请填写名称",
        	            msg: {
        	            	required: "名称不可以为空!",
        	            }
        	        }
        	    }
        	});
		  $('#add_form').on('valid.form', function(e, form){
		  	   //成功之后刷新gd，关闭自己
			   var data=$(this).serialize();
				//提交表单
               $ .axsf('admin/content/add',data,function(d){
			   		if(d){
                         if(d.code==200){
                        	 history.go(-1);
                         }else{
						 	alert(d.message);
						 }
                	}
			   });
        });
		 /**********************tree***************************/
		  var setting = {
					callback: {
						onClick: zTreeOnClick
					},
					data: {
						key: {
							name: "text",
							url: "xUrl"
						}
					}
				};
	    var zNodes =${cate_tree};
	    
		  $ .fn.zTree.init($("#category_id_tree"), setting, zNodes);
		  
		   $('#category_id_name').click(function(){
				if($('#category_id_tree_wrap').css('display')=='none'){
					$('#category_id_tree_wrap').css('display','block');
				}else{
					$('#category_id_tree_wrap').css('display','none');
				}
			});
			
			//修改模拟
			setTreeValue('category_id');
			
			function setTreeValue(id){
						var id=$('#'+id).val();
						var treeObj = $ .fn.zTree.getZTreeObj("category_id_tree");
						var nodes = treeObj.getNodesByParam("id", id, null);
						if(nodes.length==1){
							$('#category_id_select_text').html(nodes[0].text);	
							treeObj.selectNode(nodes[0]);
						}
				     }
			function zTreeOnClick(event, treeId, treeNode) {
					   // alert(treeNode.tId + ", " + treeNode.text);
						   $('#category_id').val(treeNode.id);
						   $('#category_id_select_text').html(treeNode.text);
						   $('#category_id_tree_wrap').css('display','none');
		    };
});
    </script>
</@t.html>